package tech.eyao.hs60x.converts;

import java.util.List;
import java.util.stream.Collectors;
import org.springframework.util.CollectionUtils;
import tech.eyao.hs60x.dto.StepDTO;
import tech.eyao.hs60x.model.domain.StepDO;

public class StepConvert {
	
	public static List<StepDTO> convert(List<StepDO> list) {
		if(!CollectionUtils.isEmpty(list)) {
			return list.stream().map(s-> {
				StepDTO dto = new StepDTO();
				dto.id = s.getId();
				dto.nickName = s.getNickName();
				dto.step = s.getStep();
				dto.stepDate = s.getSetpDate().getTime();
				return dto;
			}).collect(Collectors.toList());
		}
		return null;
	}

	public static StepDTO convertDTO(boolean favour, StepDO stepDO) {
		if(stepDO == null) {
			return null;
		}
 		StepDTO dto = new StepDTO();
		dto.id = stepDO.getId();
		dto.nickName = stepDO.getNickName();
		dto.step = stepDO.getStep();
		dto.stepDate = stepDO.getSetpDate().getTime();
		dto.favour = favour;
		return dto;
	}
}
